<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CompanyMenu extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('company_menu', ['comment' => '集团菜单表']);
        $table->addColumn('pid', 'integer', ['comment' => '父id', 'limit' => 11, 'default' => 0])
              ->addColumn('company_id', 'integer', ['comment' => '集团id', 'limit' => 11, 'default' => 0])
              ->addColumn('title', 'string', ['comment' => '名称', 'limit' => 100, 'default' => ''])
              ->addColumn('icon', 'string', ['comment' => '菜单图标', 'limit' => 100, 'default' => ''])
              ->addColumn('href', 'string', ['comment' => '链接', 'limit' => 100, 'default' => ''])
              ->addColumn('api','string', ['comment' => '接口', 'limit' => 100, 'default' => ''])
              ->addColumn('params', 'string', ['comment' => '链接参数', 'limit' => 500, 'default' => ''])
              ->addColumn('target', 'string', ['comment' => '链接打开方式', 'limit' => 20, 'default' => '_self'])
              ->addColumn('sort', 'integer', ['comment' => '菜单排序', 'limit' => 11, 'default' => 0])
              ->addColumn('status', 'integer', ['comment' => '状态：1启用 2禁用', 'limit' => 1, 'default' => 1])
              ->addColumn('menu_type','integer', ['comment' => '菜单类型(0:目录,1:菜单,2:按钮)', 'limit' => 1, 'default' => 3])
              ->addColumn('file_path','string', ['comment' => '文件路径', 'limit' => 255, 'default' => ''])
              ->addColumn('remark', 'string', ['comment' => '备注', 'limit' => 255, 'default' => ''])
              ->addColumn('create_time', 'integer', ['comment' => '创建时间', 'default' => null])
              ->addColumn('update_time', 'integer', ['comment' => '更新时间', 'default' => null])
              ->addColumn('delete_time', 'integer', ['comment' => '删除时间', 'default' => null])
              ->addIndex('title')
              ->addIndex('href')
              ->addIndex('company_id')
              ->create();
    }
}
